const router = require('./index');
const { Users } = require('../model');
const { Sequelize, DataTypes } = require('sequelize');



let userLogin_fn = async (ctx, next) => {

   let username = ctx.request.body.username || ''
   let password = ctx.request.body.password || ''

   let list = await Users.findAll({
      where: { username: username, password: password }
   })

   console.log('==============');
   console.log(list.length);
   if(list.length>0){
       ctx.body={
          code:1000,
          data:list,
          msg:'登录成功'
       }
   }else{
      ctx.body={
         code:400,
         data:list,
         msg:'登录失败'
      }
   }

   /* console.log(user_pwd); */
  /*  if (user_pwd.length > 0) {
      ctx.body = '登录成功'
   } else {
      ctx.body = '用户名或密码有误！'
   } */

}




module.exports = {

   "post /login": userLogin_fn,

}
